package de.mmis.core.base.device;

import java.util.HashMap;
import java.util.Map;


/**
 * a simple {@link Device} implementation wrapping an object that is presumed to
 * be always accessible
 * 
 * @author Christian Koch
 * 
 * @param <D>
 *            type of the device to wrap
 */
public class StaticDevice<D> extends AbstractDevice<D> {

	private D device;
	private String id;
	private Map<String, Object> propertyMap;

	/**
	 * creates new {@link StaticDevice} wrapping given object with given ID and
	 * empty property map
	 * 
	 * @param device
	 *            object to wrap, must not be <code>null</code>
	 * @param id
	 *            unique ID of this device
	 */
	public StaticDevice(D device, String id) {
		this(device, id, new HashMap<String, Object>());
	}

	/**
	 * creates new {@link StaticDevice} wrapping given object with given ID and
	 * property map
	 * 
	 * @param device
	 *            object to wrap, must not be <code>null</code>
	 * @param id
	 *            unique ID of this device
	 * @param propertyMap
	 *            mapping of custom properties of this device
	 */
	public StaticDevice(D device, String id, Map<String, Object> propertyMap) {
		super(true);

		if (device == null)
			throw new NullPointerException("device must not be null");
		this.device = device;
		this.id = id;
		this.propertyMap = propertyMap;
	}

	@Override
	public D getDevice() {
		return this.device;
	}

	@Override
	public String getID() {
		return this.id;
	}

	@Override
	public Map<String, Object> getPropertyMap() {
		return propertyMap;
	}

}
